package com.tpc.client.modules.core.dashboard;

import java.util.Date;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;
import com.tpc.client.systeme.core.Systeme;
import com.tpc.client.systeme.core.TPCT_MODULE;

/**
 * @version 0.0.1
 * @author frederic.fortin
 * @modified 2010-08-15
 */

public class DashboardUi implements TPCT_MODULE {

    Systeme systeme;
    String MODULEID;
    Canvas cnvHomePage = new Canvas();
    
    Boolean isUiLoaded = false;
    
    public DashboardUi() {
        
    }

    public Canvas loadUI(Systeme systemeParam,String MODULEIDp) {
        if (!isUiLoaded) {
            systeme = systemeParam;
            MODULEID = MODULEIDp;
            cnvHomePage = systeme.getTabpaneTemplate(cnvHomePage);
            cnvHomePage.setID("CANVAS_DASHBOARD");
            
            Date today = new Date();
            
                HLayout dashboardTable = new HLayout();
                dashboardTable.setWidth100();
                dashboardTable.setHeight("*");
                dashboardTable.setMembersMargin(20);
                dashboardTable.setLayoutMargin(20);
                
	                String leftRowContent ="<table width=220 height=100%><tr style=\"background-color: #E7E7E7\"><td style=\"font-family:calibri; font-size: 14pt; border-bottom: 1px solid #C0C3C7; height: 25px;\">&nbsp;&nbsp;<B>AGENDA</B></td></tr>";
	                leftRowContent += "<tr><td height=2>&nbsp;</td></tr><tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>17 oct 2012</B><br><B>SERP</B> vérification Backup</td></tr>";
	                leftRowContent += "<tr style=\"background-color: #F5F5F5\"><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>17 oct 2012</B><br><B>SERP</B> vérification Backup</td></tr>";
	                leftRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>17 oct 2012</B><br><B>SERP</B> vérification Backup</td></tr>";
	                leftRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>17 oct 2012</B><br><B>SERP</B> vérification Backup</td></tr>";
	                leftRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>17 oct 2012</B><br><B>SERP</B> vérification Backup</td></tr>";
	                leftRowContent += "</table>";
                
            		HTMLFlow leftColumn = new HTMLFlow(leftRowContent);
            		leftColumn.setWidth(220);
            		
            		String rightRowContent ="<table width=100% height=100%><tr style=\"background-color: #E7E7E7\"><td style=\"font-family:calibri; font-size: 14pt; border-bottom: 1px solid #C0C3C7; height: 25px;\">&nbsp;&nbsp;<B>Activités récentes</B></td></tr>";
            		rightRowContent += "<tr><td height=2>&nbsp;</td></tr>";
            		rightRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>Requête</B> : Servir+ : Imprimante Canon IRC - 520 ne répond pas<BR><I><font color=red>ajout</font> - 10 oct 2012 15:25 - JFLA</I></td></tr>";
            		rightRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>Requête</B> : Lafond et Associés : ajout nouvel usager réseau et courriel<BR><I><font color=red>modification</font> - 10 oct 2012 14:35 - JFLA</I></td></tr>";
            		rightRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>Organisation</B> : Nouveau client :  Bombardier<BR><I><font color=red>ajout</font> - 10 oct 2012 14:31 - FRED</I></td></tr>";
            		rightRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>Requête</B> : <B>SERP</B> Imprimante Canon IRC - 520 ne répond pas<BR><I>10 oct 2012 10:25 - JFLA</I></td></tr>";
            		rightRowContent += "<tr><td valign=top width=100% style=\"border-bottom: 1px solid #C0C3C7; font-family: calibri; font-size: 11pt\"><B>Requête</B> : <B>SERP</B> Imprimante Canon IRC - 520 ne répond pas<BR><I>10 oct 2012 10:25 - JFLA</I></td></tr>";
            		rightRowContent += "</table>";
                
            		HTMLFlow rightColumn = new HTMLFlow(rightRowContent);
            		rightColumn.setWidth("*");
            		
        		dashboardTable.addMember(leftColumn);
        		dashboardTable.addMember(rightColumn);
            
            cnvHomePage.addChild(dashboardTable);
            
            isUiLoaded = true;
        }
        // should stop loading inside datasource once we got all the information
        systeme.stopLoading();
        return cnvHomePage;
    }

    
    // compatible to implement TPC_MODULE
    public void create(ListGridRecord record) {}
    // show and create should reload list
    public DynamicForm showAndCreate(ListGridRecord record) { return null; }
    public void buildForm() {}
    public void loadForm(ListGridRecord record) {}
    public DynamicForm getForm() { return null; }
    public void buildList() {}
    public void loadList() { systeme.stopLoading(); }
    public ListGrid getList() { return null; }

}